<template>
  <div id="app">
    <div class="paddingTop" :style="'height:' + paddingTop + 'px'"></div>
    <div :style="'height:' + paddingTop + 'px;background:#fff;'"></div>
    <transition name="van-fade">
      <keep-alive>
        <router-view v-if="$route.meta.keepAlive"> </router-view>
      </keep-alive>
    </transition>
    <transition name="van-fade">
      <router-view v-if="!$route.meta.keepAlive"> </router-view>
    </transition>
  </div>
</template>
<script>
export default {
  data() {
    return {
      paddingTop: 0
    };
  },
  methods: {
    getQueryVariable(variable) {
      var query = window.location.href.split("?")[1];
      if (!query) return "";
      var vars = query.split("&");
      for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
          return pair[1];
        }
      }
      return "";
    }
  },
  created() {
    let paddingTop = this.getQueryVariable("paddingTop");
    if (!paddingTop) paddingTop = 0;
    if ((paddingTop + "").endsWith("#/"))
      paddingTop = paddingTop.replace("#/", "");
    this.paddingTop = paddingTop;
    window.sessionStorage.setItem("paddingTop", paddingTop);
    this.$api.GetSysInfo();
    let v = this.getQueryVariable("v");
    if (v) {
      this.$router.push(v);
    }
    // let uid = this.getQueryVariable("uid");
    // if (uid) {
    //   console.log(uid);
    //   let token = this.getQueryVariable("token");
    //   let userInfo = {
    //     id: uid,
    //     token: token
    //   };
    //   window.sessionStorage.setItem("u", JSON.stringify(userInfo));
    // }
  }
};
</script>
<style lang="less">
html,
body,
#app {
  margin: 0;
  padding: 0;
  margin: auto;
  background: #fff;
}
.paddingTop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #fff;
  z-index: 9999999;
}
</style>
